WPS Office.apk(点击下载) / fbp.java


package defpackage;

import android.app.Activity;
import android.app.LoaderManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Loader;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import cn.wps.moffice.OfficeApp;
import cn.wps.moffice.common.beans.OnResultActivity;
import cn.wps.moffice.common.google.pay.restore.RestorePurchaseFailActivity;
import cn.wps.moffice.common.google.signin.GoogleSignInActivity;
import cn.wps.moffice.extlibs.Qing3rdLoginConstants;
import cn.wps.moffice_eng.R;
import com.google.gson.reflect.TypeToken;
import com.iflytek.cloud.SpeechEvent;
import org.json.JSONObject;

/* renamed from: fbp  reason: default package */
public final class fbp {
    a fzJ;
    int fzK;
    boolean fzL = false;
    Context mContext;
    Handler mHandler = new Handler(Looper.getMainLooper());

    /* renamed from: fbp$a */
    public interface a {
        void btd();
    }

    /* renamed from: fbp$b */
    class b implements LoaderManager.LoaderCallbacks<Integer> {
        b() {
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final Loader<Integer> onCreateLoader(int i, Bundle bundle) {
            fvl.cZ(fbp.this.mContext);
            fbv btv = fbv.btv();
            Context context = fbp.this.mContext;
            String aIB = dng.aIB();
            hwe hwe = new hwe();
            hwe.dk("account", aIB);
            btv.fAO.a(hwe);
            return new log(context).HX("https://movip.wps.com/template/v2/user/credits").b(new TypeToken<Integer>() {
                /* class defpackage.fbv.AnonymousClass13 */
            }.getType()).u(hwe.cmr());
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.content.Loader, java.lang.Object] */
        @Override // android.app.LoaderManager.LoaderCallbacks
        public final /* synthetic */ void onLoadFinished(Loader<Integer> loader, Integer num) {
            Integer num2 = num;
            fvl.dd(fbp.this.mContext);
            if (num2 == null) {
                lvg.d(fbp.this.mContext, R.string.server_error, 0);
                return;
            }
            int intValue = num2.intValue();
            fbp fbp = fbp.this;
            Context context = fbp.this.mContext;
            fbp.fzK = intValue;
            czq czq = new czq(context);
            View inflate = LayoutInflater.from(context).inflate(R.layout.foreign_template_account_binding_dialog, (ViewGroup) null);
            ((TextView) inflate.findViewById(R.id.restore_bind_credits_show)).setText(String.valueOf(intValue));
            czq.setView(inflate);
            czq.setNegativeButton(R.string.public_cancel, new DialogInterface.OnClickListener() {
                /* class defpackage.fbp.AnonymousClass6 */

                public final void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                }
            });
            czq.setPositiveButton(R.string.foreign_account_binding, fbp.mContext.getResources().getColor(R.color.phone_home_color_red), new DialogInterface.OnClickListener() {
                /* class defpackage.fbp.AnonymousClass7 */

                public final void onClick(final DialogInterface dialogInterface, int i) {
                    fbq.hu("public_template_binding");
                    fcx.p(new Runnable() {
                        /* class defpackage.fbp.AnonymousClass7.AnonymousClass1 */

                        public final void run() {
                            fbp fbp = fbp.this;
                            DialogInterface dialogInterface = dialogInterface;
                            fvl.cZ(fbp.mContext);
                            try {
                                boolean pH = fbv.btv().pH(dng.aIB());
                                dialogInterface.dismiss();
                                fbp.mHandler.post(new Runnable(pH) {
                                    /* class defpackage.fbp.AnonymousClass9 */
                                    final /* synthetic */ boolean fzS;

                                    {
                                        this.fzS = r2;
                                    }

                                    public final void run() {
                                        fvl.dd(fbp.this.mContext);
                                        if (this.fzS) {
                                            fbq.hu("public_restore_template_success");
                                            if (fbp.this.fzJ != null) {
                                                fbp.this.fzJ.btd();
                                                return;
                                            }
                                            return;
                                        }
                                        fbq.hu("public_restore_template_bindingothers");
                                        RestorePurchaseFailActivity.a((OnResultActivity) fbp.this.mContext, String.format(fbp.this.mContext.getString(R.string.foreign_account_binding_fail_tip), Qing3rdLoginConstants.WPS_UTYPE), Qing3rdLoginConstants.WPS_UTYPE, null);
                                    }
                                });
                            } catch (Exception e) {
                                e.printStackTrace();
                                fvl.dd(fbp.mContext);
                                lvg.d(fbp.mContext, R.string.public_network_error, 0);
                            }
                        }
                    });
                }
            });
            czq.show();
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final void onLoaderReset(Loader<Integer> loader) {
        }
    }

    public fbp(Context context, a aVar) {
        this.mContext = context;
        this.fzJ = aVar;
    }

    public final void az(final View view) {
        if (!ebo.arU()) {
            view.setVisibility(8);
        } else if (lwd.hu(this.mContext)) {
            if (this.fzL) {
                this.mHandler.post(new Runnable() {
                    /* class defpackage.fbp.AnonymousClass4 */

                    public final void run() {
                        view.setVisibility(4);
                    }
                });
            }
            fcx.p(new Runnable() {
                /* class defpackage.fbp.AnonymousClass5 */

                public final void run() {
                    try {
                        fbv btv = fbv.btv();
                        String bE = ebo.bE(OfficeApp.arx());
                        hwe hwe = new hwe();
                        hwe.dk("wpsid", bE);
                        hwe.dk("version", "2");
                        btv.fAO.a(hwe);
                        final Boolean valueOf = Boolean.valueOf("has bind".equalsIgnoreCase(new JSONObject(dnd.a("https://movip.wps.com/template/v2/user/checkWpsidBind", hwe.cmq(), null)).getString(SpeechEvent.KEY_EVENT_RECORD_DATA)));
                        fbp.this.mHandler.post(new Runnable() {
                            /* class defpackage.fbp.AnonymousClass5.AnonymousClass1 */

                            public final void run() {
                                if (valueOf != null) {
                                    fbp.this.fzL = valueOf.booleanValue();
                                    view.setVisibility(valueOf.booleanValue() ? 4 : 0);
                                }
                            }
                        });
                    } catch (Exception e) {
                        e.printStackTrace();
                        lvg.d(fbp.this.mContext, R.string.public_network_error, 0);
                    }
                }
            });
        }
    }

    public final void btp() {
        czq czq = new czq(this.mContext);
        czq.setMessage(R.string.public_purchase_to_signin_google);
        czq.setNegativeButton(R.string.public_cancel, new DialogInterface.OnClickListener() {
            /* class defpackage.fbp.AnonymousClass1 */

            public final void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
            }
        });
        czq.setPositiveButton(R.string.public_signin, this.mContext.getResources().getColor(R.color.phone_home_color_red), new DialogInterface.OnClickListener() {
            /* class defpackage.fbp.AnonymousClass2 */

            public final void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
                fbp fbp = fbp.this;
                GoogleSignInActivity.a((OnResultActivity) fbp.mContext, new GoogleSignInActivity.a() {
                    /* class defpackage.fbp.AnonymousClass3 */

                    @Override // cn.wps.moffice.common.google.signin.GoogleSignInActivity.a
                    public final void kF(String str) {
                        fcx.p(new Runnable() {
                            /* class defpackage.fbp.AnonymousClass3.AnonymousClass1 */

                            public final void run() {
                                String str;
                                fbp fbp = fbp.this;
                                fvl.cZ(fbp.mContext);
                                String aIB = dng.aIB();
                                try {
                                    fbv btv = fbv.btv();
                                    hwe hwe = new hwe();
                                    hwe.dk("account", aIB);
                                    btv.fAO.a(hwe);
                                    String string = new JSONObject(dnd.a("https://movip.wps.com/template/v2/user/checkGmailBind", hwe.cmq(), null)).getString(SpeechEvent.KEY_EVENT_RECORD_DATA);
                                    if (string.startsWith("has bind")) {
                                        str = Qing3rdLoginConstants.WPS_UTYPE;
                                        int indexOf = string.indexOf("loginMode:");
                                        if (indexOf > 0) {
                                            str = string.substring("loginMode:".length() + indexOf, string.length());
                                            if (TextUtils.isEmpty(str) || NotificationCompat.CATEGORY_EMAIL.equalsIgnoreCase(str)) {
                                                str = Qing3rdLoginConstants.WPS_UTYPE;
                                            }
                                        }
                                    } else {
                                        str = "";
                                    }
                                    fbp.mHandler.post(new Runnable(str) {
                                        /* class defpackage.fbp.AnonymousClass8 */
                                        final /* synthetic */ String efs;

                                        {
                                            this.efs = r2;
                                        }

                                        public final void run() {
                                            fvl.dd(fbp.this.mContext);
                                            if (TextUtils.isEmpty(this.efs)) {
                                                ((Activity) fbp.this.mContext).getLoaderManager().restartLoader(564, null, new b());
                                                return;
                                            }
                                            fbq.hu("public_restore_template_bindingothers");
                                            RestorePurchaseFailActivity.a((OnResultActivity) fbp.this.mContext, String.format(fbp.this.mContext.getString(R.string.foreign_account_binding_fail_tip), this.efs), this.efs, null);
                                        }
                                    });
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    fvl.dd(fbp.mContext);
                                    lvg.d(fbp.mContext, R.string.public_network_error, 0);
                                }
                            }
                        });
                    }
                });
            }
        });
        czq.show();
        fbq.hu("public_restore_template");
    }
}